package nc.tb.perm.table;

import java.awt.Component;

import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;


public class PermTableCellRender extends DefaultTableCellRenderer {

	public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
		Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		if (table != null && c != null && c instanceof JComponent) {
			TableModel model = table.getModel();
			if (model != null && model instanceof IPermTableModel) {
				String tip = ((IPermTableModel)model).getTipTextAt(row, column);
				if (tip != null && tip.length() > 0)
					((JComponent)c).setToolTipText(tip);
			}
		}
		return c;
	}
}
